package com.wang;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * @ProjectName: untitled
 * @Titile: CollectionsDemo
 * @Author: 王亦凡1
 * @Description: TODO
 * 演示collections工具类
 */
public class CollectionsDemo {
    public static void main(String[] args) {
       test0();
       test1();

    }
    public static void test0(){    List<String> list = new LinkedList<>();
        Collections.addAll(list,"王彪","张三","李四","张博文");
        list.forEach(System.out::println);
        //打乱集合顺序
        Collections.shuffle(list);
        list.forEach(System.out::println);}

    public  static void test1(){

        List<Integer>list = new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5,6,7,8,9);
        Collections.sort(list);
        list.forEach(System.out::println);
        Collections.sort(list,(o1, o2) -> {return o2-o1;});
        System.out.println("------------------");
        list.forEach(System.out::println);
        System.out.println("--------------------");
        List<Student>list1=new ArrayList<>();
        list1.add(new Student("wnagbao",22));
        list1.add(new Student("zhangsan",22));
        list1.add(new Student("lisi",22));
        Collections.sort(list1);
        list1.forEach(System.out::println);






    }
}
